﻿@* Generator: Template *@
@functions { public dynamic Model { get; set; } }@{
    var dotModule = Model.Module == null ? "" : ("." + Model.Module);
    var moduleDot = Model.Module == null ? "" : (Model.Module + ".");
     
    Func<string, string, string> jf = (x, y) =>
    {
        if (x.ToLowerInvariant() == y.ToLowerInvariant())
            return y;
        else
            return x + y;
    };

    Func<EntityField, string> gt = (x) =>
    {
        return (x.FieldType == "Stream" || x.FieldType == "ByteArray" ? "byte[]" : (x.FieldType == "DateTime" ? "String" : (x.FieldType + (x.IsValueType ? "?" : ""))));
    };
}
using jQueryApi;
using Serenity;
using Serenity.ComponentModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace @(Model.RootNamespace)@(dotModule)
{
    [Imported, Serializable, PreserveMemberCase]
    public partial class @Model.RowClassName
    {@if (Model.Identity != null) {<text>
        [InlineConstant] public const string IdProperty = "@(Model.Identity)";</text>}@if (Model.NameField != null) {<text>
        [InlineConstant] public const string NameProperty = "@(Model.NameField)";</text>}

        [InlineConstant] public const string LocalTextPrefix = "@moduleDot@Model.ClassName";
@foreach (EntityField x in Model.Fields) {
<text>
        public @gt(x) @x.Ident { get; set; }</text>}
@foreach (EntityJoin x in Model.Joins){foreach (EntityField y in x.Fields){
<text>
        public @gt(y) @(jf(x.Name, y.Ident)) { get; set; }</text>}}


        [Imported, PreserveMemberCase]
        public static class Fields
        {@foreach (EntityField x in Model.Fields) {
<text>
            [InlineConstant] public const string @x.Ident = "@(x.Ident)";</text>}
@foreach (EntityJoin x in Model.Joins){foreach (EntityField y in x.Fields){
<text>
            [InlineConstant] public const string @(jf(x.Name, y.Ident)) = "@(jf(x.Name, y.Ident))";</text>}}

        }
    }
}